package work10;

import java.util.Scanner;

/**
 * @author ybb
 * 练习1：字符串反转
举例：键盘录入”abc”	输出结果：”cba”
提示：toCharArray()将字符串转为一个字符数组

 */
public class Task01 {
    public static void main(String[] args) {
        System.out.println("请输入一段字符:");
        Scanner scan = new Scanner(System.in);
        String s = scan.next();
        System.out.println("反转输出：");
        System.out.print(text(s));
        }

        public static String text(String s){
            char[] c = s.toCharArray();
            StringBuffer str = new StringBuffer();
            for(int i=c.length-1;i>=0;i--){
                str.append(c[i]);
            }
            return str.toString();
        }

}

